package it11.Capood.GUI;

import it11.Capood.R;
import it11.Capood.DataLogic.BluetoothService;
import it11.Capood.DataLogic.ClipListenService;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;
import android.view.View;

public class MainActivity extends Activity {
	
	private SharedPreferences prefs;
	
	//preferences
	static final public String PREF_CAPOOD = "pref_capood";
	static final public String PREF_FIRST_START = "pref_first_start";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		prefs = getSharedPreferences(MainActivity.PREF_CAPOOD, Context.MODE_PRIVATE);
		
		if (prefs.getBoolean(PREF_FIRST_START, true)){
			startService(new Intent(this,BluetoothService.class));
			startService(new Intent(this,ClipListenService.class));
			SharedPreferences.Editor editor = prefs.edit();
			editor.putBoolean(PREF_FIRST_START, false);
			editor.putBoolean(BluetoothService.PREF_BLUETOOTH_SERVICE, true);
			editor.putBoolean(ClipListenService.PREF_CLIP_SERVICE, true);
			editor.apply();
		} /*else {
			if (prefs.getBoolean(ClipListenService.PREF_CLIP_SERVICE, false)){
				startService(new Intent(this,ClipListenService.class));
			}
			
			if (prefs.getBoolean(BluetoothService.PREF_BLUETOOTH_SERVICE, false)){
				startService(new Intent(this,BluetoothService.class));
			}
		}*/
		
		if (prefs.getBoolean(PREF_FIRST_START, true)){
			Log.d("haha","haha");
		}
		
		
	}

	public void click_send_text(View view){
		
		Intent intent = new Intent(this,SendingTextActivity.class);
		
		startActivity(intent);
	}
	
	public void click_send_file(View view){
		Intent intent = new Intent(this,SendingFileActivity.class);
		
		startActivity(intent);
	}
	
	public void click_history(View view){
		Intent intent = new Intent(this,HistoryActivity.class);
		
		startActivity(intent);
	}
	
	public void click_setting(View view){
		Intent intent = new Intent(this,SettingsActivity.class);
		
		startActivity(intent);
	}
}
